
$(function () {
    $('#USERID').on('mouseleave',function () {
        var id=$(this).val();
        if(id !== ''||id !== null){
            $.ajax({
                type:'GET',
                url:'http://localhost:8080/web_war_exploded/idValid?id='+id,
                success:function (text) {
                    console.log(text);
                    if(text !==''&&text !==null){
                        var HTML='';
                        HTML+=text;
                        $('#IdMsg').html(HTML);
                        $('#IdMsg').show();
                        $('.user-form-submit').attr('disabled',true);
                    }
                    else {
                        $('#IdMsg').hide();
                        $('.user-form-submit').attr('disabled',false);
                    }
                },
                error:function (errorMsg) {
                    console.log('114');
                    console.log(errorMsg);
                }
            })
        }
    })
    $('#USERID1').on('keyup',function () {
        var id=$(this).val();
        if(id !== null ||id.length>0){
            $.ajax({
                type:'GET',
                url:'http://localhost:8080/web_war_exploded/idValid?id='+id,
                success:function (text) {
                    console.log(text);
                    if(text !==''&&text !==null){
                        var HTML='';
                        HTML+=text;
                        $('#IdMsg').html(HTML);
                        $('#IdMsg').show();
                        $('.user-form-submit').attr('disabled',true);
                    }
                    else {
                        $('#IdMsg').hide();
                        $('.user-form-submit').attr('enabled',false);
                    }
                },
                error:function (errorMsg) {
                    console.log('114');
                    console.log(errorMsg);
                }
            });
        }
        else{
            let temp = '';
            temp+='UserId can';
            temp+='\'';
            temp+='t be vacant.';
            $('#IdMsg').html(temp);
            $('#IdMsg').show();
            $('.user-form-submit').attr('disabled',true);
        }
    })
})